﻿<%@ Page Title="" Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<%@ Import Namespace="DoAnPhatTrienPhanMem.Controllers" %>
<%@ Import Namespace="DoAnPhatTrienPhanMem.Models" %>
<%@ Import Namespace="DoAnPhatTrienPhanMem.Constants" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <script src="/Scripts/CommonFunction.js" type="text/javascript"></script>
    <script src="/Scripts/Constant.js" type="text/javascript"></script>
    <link href="/Content/MainStyle.css" rel="stylesheet" type="text/css" />
    <script runat="server">
        private void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var user = "";
                if (Session[Constants.SessionName.UserName] != null) user = Session[Constants.SessionName.UserName].ToString();
                var AccountCtrl = new AccountController();
                Ext.Net.MenuItem node;

                if (AccountCtrl.CheckRole(user, "Canbo", "Index"))
                {
                    node = new Ext.Net.MenuItem { Text = "Danh mục cán bộ" };
                    node.Listeners.Click.Handler = "CommonFunction.loadPage('Canbo','Index', '');";
                    MainMenu.Menu.Add(node);
                }
                if (AccountCtrl.CheckRole(user, "Home", "About"))
                {
                    node = new Ext.Net.MenuItem { Text = "Các hoạt động" };
                    node.Listeners.Click.Handler = "CommonFunction.loadPage('Home','About', '');";
                    node.Disabled = true;
                    MainMenu.Menu.Add(node);
                }
                if (AccountCtrl.CheckRole(user, "Home", "About"))
                {
                    node = new Ext.Net.MenuItem { Text = "Các đề tài nghiên cứu khoa học" };
                    node.Listeners.Click.Handler = "CommonFunction.loadPage('Home','About', '');";
                    node.Disabled = true;
                    MainMenu.Menu.Add(node);
                }
                if (AccountCtrl.CheckRole(user, "Home", "About"))
                {
                    node = new Ext.Net.MenuItem { Text = "Báo cáo, thống kế" };
                    node.Listeners.Click.Handler = "CommonFunction.loadPage('Home','About', '');";
                    node.Disabled = true;
                    MainMenu.Menu.Add(node);
                }
                if (AccountCtrl.CheckRole(user, "Home", "About"))
                {
                    node = new Ext.Net.MenuItem { Text = "Danh sách địa chỉ liên hệ" };
                    node.Listeners.Click.Handler = "CommonFunction.loadPage('Home','About', '');";
                    node.Disabled = true;
                    MainMenu.Menu.Add(node);
                }

                if (!String.IsNullOrEmpty(user))
                {
                    frmLogin.Hidden = true;
                    btnLogin.Hidden = true;
                    UserID.Text = user;
                    //UserID.NavigateUrl = "#";
                    UserID.Hidden = false;
                    afterLogin.Hidden = false;
                    var MaCB = AccountCtrl.GetByUserName(user).MaCB;
                    if (MaCB != null)
                    {
                        var CanBoCtrl = new CanBoController();
                        var IDcanbo = CanBoCtrl.GetSoYeuCanBoByMaCB(MaCB.ToString()).ID;
                        UserID.Listeners.Click.Handler = "CommonFunction.loadPage('CanBo','Details',{ID: '" + IDcanbo + "'});";
                    }
                }

                if (AccountCtrl.CheckRole(user, "Account", "Index"))
                {
                    node = new Ext.Net.MenuItem { Text = "Quản lý tài khoản" };
                    node.Listeners.Click.Handler = "CommonFunction.loadPage('Account','Index', '');";
                    MainMenu.Menu.Add(node);
                    node = new Ext.Net.MenuItem { Text = "Cấu hình hệ thống" };
                    node.Listeners.Click.Handler = "CommonFunction.loadPage('Account','Index', '');";
                    node.Disabled = true;
                    MainMenu.Menu.Add(node);
                }
            }
        }
        
    </script>
</head>
<body id="bd" class="fs3">
    <ext:ResourceManager ID="ResourceManager1" runat="server" Locale="vi-VN" CleanResourceUrl="false" />
    <div id="ja-wrapper">
        <div id="ja-container" class="wrap clearfix">
            <div class="main">
                <div class="inner clearfix">
                    <div id="ja-mainbody">
                        <div style="padding-left: 20px;">
                            <p style="font-size: 20px;">
                                Nhóm 84</p>
                            <div>
                                Phạm Xuân An - 20070052</div>
                            <div>
                                Nguyễn Văn Nam - 20072039</div>
                            <div>
                                Mai Nguyễn Thái Sơn - 20052768</div>
                            <div>
                                Đỗ Quang Trường - 20063382</div>
                            <div>
                                Phạm Xuân Trường - 20073100</div>
                        </div>
                    </div>
                    <div id="ja-colwrap">
                        <div class="ja-innerpad">
                            <div style="padding: 10px;">
                                <ext:CompositeField runat="server" ID="afterLogin" Hidden="true" LabelWidth="20">
                                    <Items>
                                        <ext:LinkButton runat="server" ID="UserID" />
                                        <ext:LinkButton runat="server" Text="(Đăng xuất)" NavigateUrl="/Account/Logout" />
                                    </Items>
                                </ext:CompositeField>
                                <ext:FormPanel runat="server" ID="frmLogin" Url="/Account/Login" Border="false" BodyBorder="false"
                                    Layout="FormLayout" AutoHeight="true" AutoWidth="true" LabelWidth="70">
                                    <Items>
                                        <ext:TextField runat="server" ID="Username" FieldLabel="Tài khoản" LabelWidth="50"
                                            AllowBlank="false" />
                                    </Items>
                                </ext:FormPanel>
                            </div>
                            <div style="padding-left: 155px;">
                                <ext:Button ID="btnLogin" runat="server" Text="Đăng nhập">
                                    <Listeners>
                                        <Click Fn="CommonFunction.submitLogin" />
                                    </Listeners>
                                </ext:Button>
                            </div>
                            <div id="Mod1" class="moduletable_menu">
                                <div class="ja-box-ct">
                                    <ul class="menu">
                                        <ext:MenuPanel runat="server" ID="MainMenu" Header="false" Border="false" />
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
